#ifndef DEBUG_H_
#define DEBUG_H_

#include <stdexcept>
#include <sstream>
#include <cstdio>
#include <cassert>

#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define AT __FILE__ ":" TOSTRING(__LINE__)

#ifdef _WIN32
#define snprintf _snprintf
#endif

#define fire_exception(message, ...) { char buff[2048] = {0}; \
	snprintf(buff, 2048, message, __VA_ARGS__); \
	std::stringstream ss; ss << buff; ss << AT; \
	throw std::runtime_error(ss.str().c_str());}

#ifdef __cplusplus
extern "C" {
#endif

extern void debug_init(void);
extern void debug_set_hook_on_crush(int signal);

extern void debug_message_box(const char* title, const char* message);

#ifdef __cplusplus
} // end extern "C"
#endif
#endif /* DEBUG_H_ */
